<input type="text" readonly="readonly" id="${field.name}Id" name="filterMap['companyName'].filterValue" class="textTest text_width_100px" ${"<#if filterMap["}"companyName"${"]??>"} value='${"${"}filterMap["companyName"].filterValue?default('')${"}"}' ${"</#if>"} />

<div id="DropdownMenu${listQueryField.orderNumber}" class="dropDD_contentDiv">
	<div style="overflow:auto;height:266px">
		<ul id="companyTree${listQueryField.orderNumber}" class="tree"></ul>
	</div>
	<div class="buttonBox" style="position:absolute;bottom:0px;background:#f3f4f4;height:30px;padding-top:4px">
		<a href="javascript:void(0);" class="button" tabindex="-1"><input type="button" onclick="window.curDDWin.saveWin();return false;" value="确认"></a>
		<a href="javascript:void(0);" class="button" tabindex="-1"><input type="button" onclick="clearCheckbox${listQueryField.orderNumber}();return false;" value="清空"></a>
	</div>
</div>
<div>
	
	<input type="hidden"  name="filterMap['${field.name}${listQueryField.orderNumber}'].filterName" value="${field.name}.id" />
	<input type="hidden"  name="filterMap['${field.name}${listQueryField.orderNumber}'].expType" value="eq" />
	<input type="hidden"  name="filterMap['${field.name}${listQueryField.orderNumber}'].isCompanyQuery" value="1" />
	<input type="hidden"  name="filterMap['${field.name}${listQueryField.orderNumber}'].fieldId"  value="${field.id}"/>
	<input type="hidden"  id="${field.name}companyId"  name="filterMap['${field.name}${listQueryField.orderNumber}'].filterValue" ${"<#if filterMap["}"${field.name}${listQueryField.orderNumber}"${"]??>"} value='${"${"}filterMap["${field.name}${listQueryField.orderNumber}"].filterValue?default('')${"}"}' ${"<#else>"} ${"<#if filterMap["}"${field.name}"${"]??>"} value='${"${"}filterMap["${field.name}"].filterValue?default('')${"}"}' ${"</#if>"} ${"</#if>"} />
	
</div>
<script language="JavaScript">
var treeObject${listQueryField.orderNumber};
var setting${listQueryField.orderNumber} = {
		asyncUrl : TDQS.CONTEXT_PATH+"company/freeTree.action?toLevelId="+${listQueryFieldCompany}, //获取节点数据的URL地址
		asyncParam : ["id"],
		async : true,
		callback : {
			click : function(event, treeId, treeNode) {
				$(document.getElementById('${field.name}Id')).val(treeNode.name);
				$(document.getElementById('${field.name}companyId')).val(treeNode.id);
				if(document.getElementById('businessInstance.company.fullPathIds')) {
					document.getElementById('businessInstance.company.fullPathIds').value = treeNode.id;
				}
				if(document.getElementById('businessInstance.company.id')) {
					document.getElementById('businessInstance.company.id').value = treeNode.id;
				}
					window.curDDWin.saveWin();
				
			},// 点击每个节点的事件:
			loadTreeSuccess : function(zTree, msg) {		
				treeObject${listQueryField.orderNumber} = zTree;
				//zTree.expandAll();
				var nodes = zTree.setting.root['nodes'];
				for(var i=0;i<nodes.length;i++) {
					zTree.expandNode(nodes[i],true,false);
				}
				if($(document.getElementById('${field.name}')).val()!='') {
					var nodes = zTree.setting.root['nodes'];
					preSelectNode${listQueryField.orderNumber}(zTree,nodes);
				}
			}
		}
	};
function controller${listQueryField.orderNumber}(){
	 $(document.getElementById('${field.name}Id')).inputStyle({
		operatorId:"companyMenuBtn${listQueryField.orderNumber}",
		operatorType:"text",
		operatorText:"选择",
		controllerWidth:120,
		operatorFun:showMenu${listQueryField.orderNumber},
		imgFun:clearCheckbox${listQueryField.orderNumber}
	});
}
addLoadEvent(controller${listQueryField.orderNumber});
//clean value
function clearCheckbox${listQueryField.orderNumber}(){
	$(document.getElementById('${field.name}companyId')).val("");
	$(document.getElementById('${field.name}Id')).val("");
	
	if(document.getElementById('businessInstance.company.fullPathIds')) {
		document.getElementById('businessInstance.company.fullPathIds').value = "";
	}
	if(document.getElementById('businessInstance.company.id')) {
		document.getElementById('businessInstance.company.id').value = "";
	}
	
	
	
		window.curDDWin.saveWin();
	//treeObject${listQueryField.orderNumber} = $("#companyTree${listQueryField.orderNumber}").zTree(setting${listQueryField.orderNumber});
}

function preSelectNode${listQueryField.orderNumber}(zTree,nodes) {
	var value = $(document.getElementById('${field.name}')).val();
	var companyId = $(document.getElementById('${field.name}companyId')).val();
	for(var i=0;i<nodes.length;i++) {
  		if(nodes[i] && nodes[i].id){
  			//if(value==nodes[i].id || value.indexOf(nodes[i].id+',')==0 || value.indexOf(','+nodes[i].id+',')>-1 || (value.indexOf(','+nodes[i].id)>-1 && value.indexOf(','+nodes[i].id) + (nodes[i].id+'').length+1+''==value.length+'')) {
  			//	nodes[i][setting${listQueryField.orderNumber}.checkedCol] = !nodes[i][setting${listQueryField.orderNumber}.checkedCol];
			//		zTree.updateNode(nodes[i],false);
			//  	zTree.expandNode(nodes[i],false,false);
  			//}
  			if(companyId == nodes[i].id) {
  				nodes[i][setting${listQueryField.orderNumber}.checkedCol] = true;
  				zTree.updateNode(nodes[i],false);
  				document.getElementById('${field.name}Id').value = nodes[i].name;
  			}
  			if(nodes[i]['nodes'] && nodes[i]['nodes'].length>0) {
		  			preSelectNode${listQueryField.orderNumber}(zTree,nodes[i]['nodes']);
		  	}
  		}
	}
}
	
function showMenu${listQueryField.orderNumber}()
{
	if(!treeObject${listQueryField.orderNumber}) {
		treeObject${listQueryField.orderNumber} = $("#companyTree${listQueryField.orderNumber}").zTree(setting${listQueryField.orderNumber});
	}
	$("input[type='button']",$('.dropDD_contentDiv')).each(function(){
						this.style.backgroundImage="url(./../theme/default/images/main/btn_normal.png)";
						$(this).hover(function(){this.style.backgroundImage="url(./../theme/default/images/main/btn_over.png)";},function(){this.style.backgroundImage="url(./../theme/default/images/main/btn_normal.png)";});
					});
	new DDWin({
				el:"DropdownMenu${listQueryField.orderNumber}"
				,dep:'divAround_${field.name}Id'
				,clickBody:'save'
			});
}

</script>
